<template>
  <div class="login">
    <div class="child">
      <a-space>
        <a-input v-model:value="host" placeholder="TDengine Service Host" @pressEnter="login" />
        <a-button type="primary" @click="login">登录</a-button>
      </a-space>
    </div>
  </div>
</template>

<script setup>
import { message, notification } from "ant-design-vue";
import { ref } from "vue";
import { useRouter } from "vue-router";
import {
  setLocalStorage,
  clearLocalStorage,
} from "../utils/localStorageHelper";

const host = ref("localhost");
const router = useRouter();

const login = function () {
  clearLocalStorage();
  if (host.value) {
    setLocalStorage("host", host.value);
    router.push("dashborad-tdengine");
  } else {
    message.warn(host.value + " host 输入不正确");
  }
};
</script>

<style scoped>
.login {
  height: 100%;
}

.child {
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>
